<template>
  <div class="flex flex-col h-full">
    <SearchContainer @reset="() => formRef.resetFields()" @search="getData()">
      <a-form ref="formRef" class="flex-1" :model="formState" :label-col="{ style: { width: '70px' } }">
        <a-form-item name="bm" class="w-1/5">
          <a-input v-model:value="formState.bm" placeholder="药品通用名/注册名称/国家药品编码" />
        </a-form-item>
      </a-form>
    </SearchContainer>
    <a-card class="mt-2 flex-1">
      <div class="flex mb-3">
        <CompressExport name="西成药" code="1301" :search-params="formState" btn-name="下载导入" class="mr-2" />
        <!-- <UploadTxt class="mr-2" :upload-url="'/api/v1/insure/downloadXCYTXT'" @success="getData">导入TXT</UploadTxt> -->
        <BaseExportTxt name="西成药" code="000230" :search-params="formState" btn-name="导出" />
      </div>
      <BaseTable :scroll="{ x: 12500 }" column-code="000230" fill :loading="loading" :data-source="tableData" bordered :pagination="pagination">
        <template #bodyCell="{ column, index }">
          <template v-if="column.dataIndex === 'xh'">
            {{ index + 1 }}
          </template>
        </template>
      </BaseTable>
    </a-card>
  </div>
</template>

<script setup>
import SearchContainer from '@/components/SearchContainer'
import BaseTable from '@/components/BaseTable'
// import UploadTxt from '../components/UploadTxt'
import BaseExportTxt from '../components/BaseExport'
import CompressExport from '../components/CompressExport'

const formRef = ref(null)
const formState = ref({ cxxm: 2 })

const { loading, tableData, getData, pagination } = useTable({
  url: '/insure/selectCXYList',
  immediate: true,
  formatParams: () => {
    return {
      stdate: formState.value.dateRange?.[0],
      eddate: formState.value.dateRange?.[1],
      bm: formState.value.bm
    }
  }
})
</script>
<style lang="less" scoped>
.ant-picker {
  width: 100%;
}
</style>
